"""
Case Type   : Compatibility
Case Name   : 验证raw函数的bool值输出
Create At   : 2024/10/21
Owner       : liu-tong-8848
Description :
              1.rawlike函数
              2.rawnlike函数
Expect      :
              1.成功
              2.成功
History     :
"""

import os
import unittest

from testcase.utils.CommonSH import CommonSH
from testcase.utils.Constant import Constant
from testcase.utils.Logger import Logger
from yat.test import Node


class SQL(unittest.TestCase):
    def setUp(self):
        self.log = Logger()
        self.Constant = Constant()
        self.primary_sh = CommonSH('PrimaryDbBmode')
        self.db_user_node = Node(node='PrimaryDbBmode')

    def test_add_dimension(self):
        self.log = Logger()
        self.log.info(f'-----{os.path.basename(__file__)} start-----')
        step1 = '--step1：rawlike函数 expect：执行成功'
        self.log.info(step1)
        sql = "select rawlike(hextoraw('deadbeef'),hextoraw('deadbeef')) as c;"
        self.log.info(sql)
        result = self.primary_sh.execut_db_sql(sql)
        self.log.info(result)
        self.assertIn("t", result, "执行失败" + step1)
        sql = " select rawlike(hextoraw('deadbeef'),hextoraw('deadbe')) as c; "
        self.log.info(sql)
        result = self.primary_sh.execut_db_sql(sql)
        self.log.info(result)
        self.assertIn("f", result, "执行失败" + step1)

        step2 = '--step2：rawnlike函数 expect：执行成功'
        self.log.info(step2)
        sql = "select rawnlike(hextoraw('deadbeef'),hextoraw('deadbeef')) as c;"
        self.log.info(sql)
        result = self.primary_sh.execut_db_sql(sql)
        self.log.info(result)
        self.assertIn("f", result, "执行失败" + step2)
        sql = "select rawnlike(hextoraw('deadbeef'),hextoraw('deadbe')) as c;"
        self.log.info(sql)
        result = self.primary_sh.execut_db_sql(sql)
        self.log.info(result)
        self.assertIn("t", result, "执行失败" + step2)

    def tearDown(self):
        self.log.info(f'-----{os.path.basename(__file__)} end-----')
